package com.llw.componentdevdemo;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.llw.annotation.BindPath;
import com.llw.common.LiveDataBus;
import com.llw.router.Router;

@BindPath("main/main")
public class MainActivity extends AppCompatActivity {

    MutableLiveData<String> liveData;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        liveData = LiveDataBus.getInstance().with("lisan",String.class);
        //接口 1对1
        //观察者  1对多
        /*liveData.observe(MainActivity.this, new Observer<String>() {
            @Override
            public void onChanged(String s) {
                Log.d("llw------>",s);
            }
        });*/
        liveData.postValue("12121212");
        liveData.observe(MainActivity.this, new Observer<String>() {
            @Override
            public void onChanged(String s) {
                Log.d("MainActivity-->",s);
            }
        });
    }

    public void jumpActivity(View view) {
        //postValue可以在任意线程下被调用
        //setValue 只能在主线程下被调用
//        liveData.postValue("123123");
        Router.getInstance().jumpActivity("login/login",null);


    }
}
